package com.ruoyi.framework.reptile.webmagic.jingcai.basketball;

import us.codecraft.webmagic.Page;
import us.codecraft.webmagic.Site;
import us.codecraft.webmagic.Spider;
import us.codecraft.webmagic.processor.PageProcessor;

/**
 * @author dzl
 * @Description TODO
 * @date 2024年07月09日 21:04:00
 */
public class JingCaiBasketBallShengFuPageProcessor implements PageProcessor {

    // 部分一：抓取网站的相关配置，包括编码、抓取间隔、重试次数等
    private Site site = Site.me().setRetryTimes(3).setSleepTime(1000);

    @Override
    public Site getSite() {
        return site;
    }

    // process是定制爬虫逻辑的核心接口，在这里编写抽取逻辑
    @Override
    public void process(Page page) {
        String rawText = page.getRawText();
        page.putField("jcData", rawText);
    }

    public static void main(String[] args) {
        Spider.create(new JingCaiBasketBallShengFuPageProcessor())
                //从"https://github.com/code4craft"开始抓
                .addUrl("https://webapi.sporttery.cn/gateway/jc/basketball/getMatchCalculatorV1.qry?poolCode=mnl&channel=c")
                .addPipeline(new JingCaiBasketBallShengFuPipeline())
                //开启5个线程抓取
                .thread(5)
                //启动爬虫
                .run();
    }

}
